using FluentNHibernate.Mapping;
using Munim.Fame.Core.DomainModels;

namespace Munim.Fame.DataAccess.NHibernate.Mapping
{
    public sealed class MediaMap : ClassMap<Media>
    {
        public MediaMap()
        {
            Id(m => m.Id);
            Map(m => m.Title);
            References(m => m.MediaType).LazyLoad();
            References(m => m.Rent).LazyLoad();
            References(m => m.Language).LazyLoad();

            HasMany(m => m.Actors).Table("CrewMap").ExtraLazyLoad();
            HasMany(m => m.Actresses).Table("CrewMap").ExtraLazyLoad();
            HasMany(m => m.Directors).Table("CrewMap").ExtraLazyLoad();
            HasMany(m => m.Categories).Table("CategoryMap").ExtraLazyLoad();
        }
    }
}